<template>
    <div>
        <el-breadcrumb separator-class="el-icon-arrow-right">
            <el-breadcrumb-item :to="{ path: '/Home' }">首页</el-breadcrumb-item>
            <el-breadcrumb-item>数据统计</el-breadcrumb-item>
            <el-breadcrumb-item>数据报表</el-breadcrumb-item>
        </el-breadcrumb>
        <el-card>
            <div id="echarts" class="echart"></div>
        </el-card>
    </div>
</template>
<script>
export default {
    data(){
        return{

        }
    },
    mounted() {
        this.getEcharts();
    },
    methods:{
        async getEcharts(){
            var echarts = require('echarts');
            var myChart = echarts.init(document.getElementById('echarts'));
            const {data:result} = await this.$http.get(`reports/type/1`);
            if(result.meta.status==200){
                this.$message.success(result.meta.msg);
                myChart.setOption({
                    title: {
                        text: '用户来源'
                    },
                    tooltip: {
                        trigger: 'axis',
                        axisPointer: {
                            type: 'cross',
                            label: {
                                backgroundColor: '#E9EEF3'
                            }
                        }
                    },
                    grid: {
                        left: '3%',
                        right: '4%',
                        bottom: '3%',
                        containLabel: true
                    },
                    legend: result.data.legend,
                    xAxis: result.data.xAxis,
                    yAxis: result.data.yAxis,
                    series: result.data.series
                });
            }else {
                this.$message.error(result.meta.msg);
            }

        }
    }
}
</script>
<style lang="less" scoped>
    .echart{
        width: 800px;
        height: 400px;
    }
</style>